home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994…tember: Reference Library / Dev.CD Sep 94.toast / Periodicals / develop / develop Issue 19 / develop 19 code / Adding GX Printing to QD Apps / Simple Sample ƒ / Simple Sample.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-15  |  5.5 KB  |  175 lines  |  [TEXT/KAHL]

  1. /*********************************************************************
  2.  
  3.     Simple Sample.h
  4.     
  5.     This is the header file for the QuickDraw GX unaware sample,
  6.     "Simple Sample."
  7.     
  8.     Additional info can be found in the related develop #19 article,
  9.     "Adding QuickDraw GX Printing to QuickDraw Applications."
  10.  
  11.     Dave Hersey, Apple Developer Technical Support.
  12.     
  13.     ——————— Edit Trail ———————
  14.     
  15.     spawned:                                        1/22/94  - dmh
  16.     cleaned up for 2nd draft of develop article:    3/10/94  - dmh
  17.     cleaned up for final:                            4/14/94  - dmh
  18.     
  19. *********************************************************************/
  20.  
  21. #include <AppleEvents.h>
  22. #include <Desk.h>
  23. #include <Events.h>
  24. #include <Files.h>
  25. #include <Fonts.h>
  26. #include <GestaltEqu.h>
  27. #include <Memory.h>
  28. #include <Packages.h>
  29. #include <Quickdraw.h>
  30. #include <Resources.h>
  31. #include <StandardFile.h>
  32. #include <stdio.h>
  33. #include <ToolUtils.h>
  34. #include <Types.h>
  35. #include <Windows.h>
  36. #include <GXExceptions.h>            // <-- Note that this does not use QuickDraw GX.
  37.  
  38.  
  39. #define    kOSEvent                    app4Evt    /* Event used by MultiFinder                    */
  40. #define    kSuspendResumeMessage        1        /* High byte of suspend/resume event message    */
  41. #define    kResumeMask                    1        /* Bit of message field for resume vs. suspend    */
  42.  
  43. #define        r_About                128            /* Our app's "About…" alert ID.                    */
  44. #define        r_BadConfig            130            /* Our app's "Bad configuration…" alert ID.        */
  45. #define        r_documentPict        128            /* Our PICT's resource ID.                        */
  46. #define        r_documentBitmap    128            /* Our ICON's resource ID.                        */
  47.  
  48. #define        kMyDocCreator        'SSam'        /* Our app's creator.                            */
  49. #define        kMyDocType            'aDoc'        /* Our document file type.                        */
  50. #define        kMyPageCountType    'Pgs?'        /* Our page count resource type.                */
  51. #define        kMyPageCountID        2000        /* Our page count resource ID.                    */
  52. #define        kMyPrintRecType        'THPR'        /* Our print record resource type.                */
  53. #define        kMyPrintRecID        1000        /* Our print record resource ID.                */
  54.  
  55. #define        kDefaultTitle        ((char *) "\pUntitled Document")
  56.  
  57. // Various PicComments:
  58.  
  59. #define        PostScriptBegin        190
  60. #define        PostScriptEnd        191
  61. #define        PostScriptHandle    192
  62.  
  63.  
  64. /*
  65.     MyDocumentRec - This structure contains information that we store
  66.     about each document we open or create.  We store a handle to one
  67.     of these beasties in each window's refCon field.  Note that the
  68.     MyDocumentRec data type in this example is simplified to handle a
  69.     maximum of 20 pages.
  70. */
  71.  
  72. #define kMaxPages    20
  73.  
  74. typedef struct MyDocumentRec {
  75.         THPrint            documentPrintHdl;            // Print Record bound to this document.
  76.         long            numPages;                    // Number of pages in this document.
  77.         long            curPage;                    // The current page that we're looking at.
  78.         FSSpec            documentFSSpec;                // The file specification for this document.
  79.         Str31            documentTitle;                // The title of this document (such
  80.                                                     // as "Untitled").
  81.         WindowPtr        documentWindow;                // The window for this document.
  82. } MyDocumentRec, *MyDocumentPtr;
  83.  
  84.  
  85. // globals from main.c:
  86.  
  87. extern short                 gAppResRefNum;
  88. extern Rect                 gWindowRect;
  89. extern Boolean                gQuitAfterPrinting, gQuitting, gSystemSevenIsPresent;
  90. extern long                    gSleep;
  91.  
  92.                     //  Prototypes: //
  93.  
  94. // main.c:
  95.  
  96. void            MyInitialize(void);
  97. void            MyCheckConfig(void);
  98. void            main(void);
  99.  
  100. // events.c
  101.  
  102. void            MyEventLoop(void);
  103. void            MyDoEvent(EventRecord *theEvent);
  104. void            MyDoAEInstallation(void);
  105. pascal OSErr    MyHandleOAPP(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
  106. pascal OSErr    MyHandleQUIT(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
  107. pascal OSErr    MyHandleODOC(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
  108. pascal OSErr    MyHandlePDOC(AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon);
  109. OSErr            MyCheckAEParams(AppleEvent *theAppleEvent);
  110.  
  111. // file.c
  112.  
  113. OSErr            MyLoadDocument(MyDocumentPtr whichDocument);
  114. OSErr            MyFSLoadDocument(MyDocumentPtr destDocument, FSSpec *docFSSpec, Boolean forPrinting);
  115. Boolean            MyIsWindowAlreadyOpen(FSSpec *whichFSSpec);
  116. OSErr            MySaveDocument(MyDocumentPtr myDocument, Boolean doingSaveAs);
  117. OSErr            MySavePageCount(MyDocumentPtr whichDocument, short resRefNum);
  118. long            MyLoadPageCount(short resRefNum);
  119. OSErr            MySavePrintInfo(MyDocumentPtr whichDocument, short resRefNum);
  120. OSErr            MyLoadPrintInfo(MyDocumentPtr whichDocument, short resRefNum);
  121.  
  122. // menus & windows.c:
  123.  
  124. OSErr            MyCreateDocument(char *title, MyDocumentPtr *createdDocument);
  125. void            MyDisposeDocument(MyDocumentPtr whichDocument);
  126. OSErr            MyInsertPage(MyDocumentPtr whichDocument, long *whichPage);
  127. void            MyDisposePage(MyDocumentPtr whichDocument, long whichPage);
  128. void            MyUpdateWindow(WindowPtr whichWindow);
  129. void            MyDrawContents(WindowPtr whichWindow);
  130. void            MyDrawPicComments(void);
  131. void            MySendPostScript(Str255 thePostScript);
  132. void            MyAdjustMenus(void);
  133. void            MyDoMenuCommand(long menuResult);
  134. MyDocumentPtr    MyGetDocPtr(WindowPtr whichWindow);
  135.  
  136. // printing.c:
  137.  
  138. OSErr            MyPrintDocument(MyDocumentPtr whichDocument);
  139. OSErr            MyPrintLoop(MyDocumentPtr whichDocument);
  140. Boolean            MyDoPageSetup(MyDocumentPtr whichDocument);
  141. void            MyRepaginateDoc(MyDocumentPtr whichDocument);
  142.  
  143.  
  144. // resource & menu item equates:
  145.  
  146. #define rMenuBar        128
  147. #define mApple            128
  148. #define     iAbout                1
  149.  
  150. #define mFile            129
  151. #define     iNew                1
  152. #define     iOpen                2
  153. #define     iClose                3
  154. #define     iSave                4
  155. #define     iSaveAs            5
  156. #define     iPageSetup            7
  157. #define     iPrint                8
  158. #define     iQuit                   10
  159.  
  160. #define mEdit            130
  161. #define     iUndo                1
  162. #define     iCut                3
  163. #define     iCopy                4
  164. #define     iPaste                5
  165. #define     iClear                6
  166.  
  167. #define mDocument        131
  168. #define     iInsertPage        1
  169. #define     iDeletePage        2
  170. #define     iAheadPage            4
  171. #define     iBackPage            5
  172.  
  173.  
  174.  
  175.